<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.13.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>mi-malloc: C++ wrappers</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
  $(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="mimalloc-doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="mimalloc-logo.svg"/></td>
  <td id="projectalign">
   <div id="projectname">mi-malloc<span id="projectnumber">&#160;1.8/2.1</span>
   </div>
  </td>
    <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <span id="MSearchSelect"                onmouseover="return searchBox.OnSearchSelectShow()"                onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
          <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.13.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('group__cpp.html',''); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">C++ wrappers</div></div>
</div><!--header-->
<div class="contents">

<p><code>mi_</code> prefixed implementations of various allocation functions that use C++ semantics on out-of-memory, generally calling <code>std::get_new_handler</code> and raising a <code>std::bad_alloc</code> exception on failure.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:structmi__stl__allocator" id="r_structmi__stl__allocator"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#structmi__stl__allocator">mi_stl_allocator&lt; T &gt;</a></td></tr>
<tr class="memdesc:structmi__stl__allocator"><td class="mdescLeft">&#160;</td><td class="mdescRight"><em class="arg">std::allocator</em> implementation for mimalloc for use in STL containers.  <a href="#structmi__stl__allocator">More...</a><br /></td></tr>
<tr class="separator:structmi__stl__allocator"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga633d96e3bc7011f960df9f3b2731fc6a" id="r_ga633d96e3bc7011f960df9f3b2731fc6a"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ga633d96e3bc7011f960df9f3b2731fc6a">mi_new</a> (std::size_t n) noexcept(false)</td></tr>
<tr class="memdesc:ga633d96e3bc7011f960df9f3b2731fc6a"><td class="mdescLeft">&#160;</td><td class="mdescRight">like <a class="el" href="group__malloc.html#gae1dd97b542420c87ae085e822b1229e8" title="Allocate size bytes.">mi_malloc()</a>, but when out of memory, use <code>std::get_new_handler</code> and raise <code>std::bad_alloc</code> exception on failure.  <br /></td></tr>
<tr class="separator:ga633d96e3bc7011f960df9f3b2731fc6a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadd11b85c15d21d308386844b5233856c" id="r_gadd11b85c15d21d308386844b5233856c"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#gadd11b85c15d21d308386844b5233856c">mi_new_n</a> (size_t count, size_t size) noexcept(false)</td></tr>
<tr class="memdesc:gadd11b85c15d21d308386844b5233856c"><td class="mdescLeft">&#160;</td><td class="mdescRight">like <a class="el" href="group__malloc.html#ga61f46bade3db76ca24aaafedc40de7b6" title="Allocate count elements of size bytes.">mi_mallocn()</a>, but when out of memory, use <code>std::get_new_handler</code> and raise <code>std::bad_alloc</code> exception on failure.  <br /></td></tr>
<tr class="separator:gadd11b85c15d21d308386844b5233856c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga79c54da0b4b4ce9fcc11d2f6ef6675f8" id="r_ga79c54da0b4b4ce9fcc11d2f6ef6675f8"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ga79c54da0b4b4ce9fcc11d2f6ef6675f8">mi_new_aligned</a> (std::size_t n, std::align_val_t alignment) noexcept(false)</td></tr>
<tr class="memdesc:ga79c54da0b4b4ce9fcc11d2f6ef6675f8"><td class="mdescLeft">&#160;</td><td class="mdescRight">like <a class="el" href="group__aligned.html#ga69578ff1a98ca16e1dcd02c0995cd65c" title="Allocate size bytes aligned by alignment.">mi_malloc_aligned()</a>, but when out of memory, use <code>std::get_new_handler</code> and raise <code>std::bad_alloc</code> exception on failure.  <br /></td></tr>
<tr class="separator:ga79c54da0b4b4ce9fcc11d2f6ef6675f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5cb4f120d1f7296074256215aa9a9e54" id="r_ga5cb4f120d1f7296074256215aa9a9e54"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ga5cb4f120d1f7296074256215aa9a9e54">mi_new_nothrow</a> (size_t n)</td></tr>
<tr class="memdesc:ga5cb4f120d1f7296074256215aa9a9e54"><td class="mdescLeft">&#160;</td><td class="mdescRight">like <code>mi_malloc</code>, but when out of memory, use <code>std::get_new_handler</code> but return <em class="arg">NULL</em> on failure.  <br /></td></tr>
<tr class="separator:ga5cb4f120d1f7296074256215aa9a9e54"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga92ae00b6dd64406c7e64557711ec04b7" id="r_ga92ae00b6dd64406c7e64557711ec04b7"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ga92ae00b6dd64406c7e64557711ec04b7">mi_new_aligned_nothrow</a> (size_t n, size_t alignment)</td></tr>
<tr class="memdesc:ga92ae00b6dd64406c7e64557711ec04b7"><td class="mdescLeft">&#160;</td><td class="mdescRight">like <code>mi_malloc_aligned</code>, but when out of memory, use <code>std::get_new_handler</code> but return <em class="arg">NULL</em> on failure.  <br /></td></tr>
<tr class="separator:ga92ae00b6dd64406c7e64557711ec04b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6867d89baf992728e0cc20a1f47db4d0" id="r_ga6867d89baf992728e0cc20a1f47db4d0"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ga6867d89baf992728e0cc20a1f47db4d0">mi_new_realloc</a> (void *p, size_t newsize)</td></tr>
<tr class="memdesc:ga6867d89baf992728e0cc20a1f47db4d0"><td class="mdescLeft">&#160;</td><td class="mdescRight">like <a class="el" href="group__malloc.html#ga0621af6a5e3aa384e6a1b548958bf583" title="Re-allocate memory to newsize bytes.">mi_realloc()</a>, but when out of memory, use <code>std::get_new_handler</code> and raise <code>std::bad_alloc</code> exception on failure.  <br /></td></tr>
<tr class="separator:ga6867d89baf992728e0cc20a1f47db4d0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaace912ce086682d56f3ce9f7638d9d67" id="r_gaace912ce086682d56f3ce9f7638d9d67"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#gaace912ce086682d56f3ce9f7638d9d67">mi_new_reallocn</a> (void *p, size_t newcount, size_t size)</td></tr>
<tr class="memdesc:gaace912ce086682d56f3ce9f7638d9d67"><td class="mdescLeft">&#160;</td><td class="mdescRight">like <a class="el" href="group__malloc.html#ga8bddfb4a1270a0854bbcf44cb3980467" title="Re-allocate memory to count elements of size bytes.">mi_reallocn()</a>, but when out of memory, use <code>std::get_new_handler</code> and raise <code>std::bad_alloc</code> exception on failure.  <br /></td></tr>
<tr class="separator:gaace912ce086682d56f3ce9f7638d9d67"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p><code>mi_</code> prefixed implementations of various allocation functions that use C++ semantics on out-of-memory, generally calling <code>std::get_new_handler</code> and raising a <code>std::bad_alloc</code> exception on failure. </p>
<p>Note: use the <code>mimalloc-new-delete.h</code> header to override the <em class="arg">new</em> and <em class="arg">delete</em> operators globally. The wrappers here are mostly for convenience for library writers that need to interface with mimalloc from C++. </p>
<hr/><h2 class="groupheader">Data Structure Documentation</h2>
<a name="structmi__stl__allocator" id="structmi__stl__allocator"></a>
<h2 class="memtitle"><span class="permalink"><a href="#structmi__stl__allocator">&#9670;&#160;</a></span>mi_stl_allocator</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct mi_stl_allocator</td>
        </tr>
      </table>
</div><div class="memdoc">
<div class="textblock"><div class="compoundTemplParams">template&lt;class T&gt;<br />
struct mi_stl_allocator&lt; T &gt;</div><p><em class="arg">std::allocator</em> implementation for mimalloc for use in STL containers. </p>
<p>For example: </p><div class="fragment"><div class="line">std::vector&lt;int, mi_stl_allocator&lt;int&gt; &gt; vec;</div>
<div class="line">vec.push_back(1);</div>
<div class="line">vec.pop_back();</div>
</div><!-- fragment --> </div>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga633d96e3bc7011f960df9f3b2731fc6a" name="ga633d96e3bc7011f960df9f3b2731fc6a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga633d96e3bc7011f960df9f3b2731fc6a">&#9670;&#160;</a></span>mi_new()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * mi_new </td>
          <td>(</td>
          <td class="paramtype">std::size_t</td>          <td class="paramname"><span class="paramname"><em>n</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>like <a class="el" href="group__malloc.html#gae1dd97b542420c87ae085e822b1229e8" title="Allocate size bytes.">mi_malloc()</a>, but when out of memory, use <code>std::get_new_handler</code> and raise <code>std::bad_alloc</code> exception on failure. </p>

</div>
</div>
<a id="ga79c54da0b4b4ce9fcc11d2f6ef6675f8" name="ga79c54da0b4b4ce9fcc11d2f6ef6675f8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga79c54da0b4b4ce9fcc11d2f6ef6675f8">&#9670;&#160;</a></span>mi_new_aligned()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * mi_new_aligned </td>
          <td>(</td>
          <td class="paramtype">std::size_t</td>          <td class="paramname"><span class="paramname"><em>n</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::align_val_t</td>          <td class="paramname"><span class="paramname"><em>alignment</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>like <a class="el" href="group__aligned.html#ga69578ff1a98ca16e1dcd02c0995cd65c" title="Allocate size bytes aligned by alignment.">mi_malloc_aligned()</a>, but when out of memory, use <code>std::get_new_handler</code> and raise <code>std::bad_alloc</code> exception on failure. </p>

</div>
</div>
<a id="ga92ae00b6dd64406c7e64557711ec04b7" name="ga92ae00b6dd64406c7e64557711ec04b7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga92ae00b6dd64406c7e64557711ec04b7">&#9670;&#160;</a></span>mi_new_aligned_nothrow()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * mi_new_aligned_nothrow </td>
          <td>(</td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>n</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>alignment</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>like <code>mi_malloc_aligned</code>, but when out of memory, use <code>std::get_new_handler</code> but return <em class="arg">NULL</em> on failure. </p>

</div>
</div>
<a id="gadd11b85c15d21d308386844b5233856c" name="gadd11b85c15d21d308386844b5233856c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadd11b85c15d21d308386844b5233856c">&#9670;&#160;</a></span>mi_new_n()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * mi_new_n </td>
          <td>(</td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>count</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>size</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>like <a class="el" href="group__malloc.html#ga61f46bade3db76ca24aaafedc40de7b6" title="Allocate count elements of size bytes.">mi_mallocn()</a>, but when out of memory, use <code>std::get_new_handler</code> and raise <code>std::bad_alloc</code> exception on failure. </p>

</div>
</div>
<a id="ga5cb4f120d1f7296074256215aa9a9e54" name="ga5cb4f120d1f7296074256215aa9a9e54"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5cb4f120d1f7296074256215aa9a9e54">&#9670;&#160;</a></span>mi_new_nothrow()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * mi_new_nothrow </td>
          <td>(</td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>n</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>like <code>mi_malloc</code>, but when out of memory, use <code>std::get_new_handler</code> but return <em class="arg">NULL</em> on failure. </p>

</div>
</div>
<a id="ga6867d89baf992728e0cc20a1f47db4d0" name="ga6867d89baf992728e0cc20a1f47db4d0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6867d89baf992728e0cc20a1f47db4d0">&#9670;&#160;</a></span>mi_new_realloc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * mi_new_realloc </td>
          <td>(</td>
          <td class="paramtype">void *</td>          <td class="paramname"><span class="paramname"><em>p</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>newsize</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>like <a class="el" href="group__malloc.html#ga0621af6a5e3aa384e6a1b548958bf583" title="Re-allocate memory to newsize bytes.">mi_realloc()</a>, but when out of memory, use <code>std::get_new_handler</code> and raise <code>std::bad_alloc</code> exception on failure. </p>

</div>
</div>
<a id="gaace912ce086682d56f3ce9f7638d9d67" name="gaace912ce086682d56f3ce9f7638d9d67"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaace912ce086682d56f3ce9f7638d9d67">&#9670;&#160;</a></span>mi_new_reallocn()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * mi_new_reallocn </td>
          <td>(</td>
          <td class="paramtype">void *</td>          <td class="paramname"><span class="paramname"><em>p</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>newcount</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t</td>          <td class="paramname"><span class="paramname"><em>size</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>like <a class="el" href="group__malloc.html#ga8bddfb4a1270a0854bbcf44cb3980467" title="Re-allocate memory to count elements of size bytes.">mi_reallocn()</a>, but when out of memory, use <code>std::get_new_handler</code> and raise <code>std::bad_alloc</code> exception on failure. </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.13.1 </li>
  </ul>
</div>
</body>
</html>
